package cc.fine.svc.main.utils;

import cc.fine.svc.config.mq.RabbitmqSyncConfig;
import cc.fine.svc.main.bean.FineMessage;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.qiniu.util.Json;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @AUTHOR: wyihe
 * @DATE: 2023/10/28
 */
@Component
public class MqUtils {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    /**
     * 发送消息
     */
    public void send(FineMessage message) {

        Gson gson = new Gson();
        String json = gson.toJson(message);


        rabbitTemplate.convertAndSend(
                RabbitmqSyncConfig.EXCHANGE,
                RabbitmqSyncConfig.QUEUE,
                json);
    }
}
